package MaintMenu.SyncInventoryToCat;// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   AddNewPartLI.java



//############### STILL TESTING ##########

import java.sql.*;

// Referenced classes of package pk1:
//            DnkFunctions

public class InsertNewItemInTblinventoryTo6Mast

{

    public InsertNewItemInTblinventoryTo6Mast()
    {

        try
        {
            DnkFunctions dnk = new DnkFunctions();
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dataSourceName = "dbLI";
            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
            Connection con = DriverManager.getConnection(dbURL, "", "");
            Statement st = con.createStatement();
            Statement st1 = con.createStatement();
            Statement st2 = con.createStatement();
            Statement st3 = con.createStatement();
            Statement st4 = con.createStatement();
            Statement st5 = con.createStatement();
            Statement st6 = con.createStatement();
//            try
//            {
//                st4.execute("delete * from tblnu;");
//                st.execute((new StringBuilder()).append("select * from ").append(args[0]).toString());
//                ResultSet rs = st.getResultSet();
//                if(rs != null)
//                {
//                    String DESCRIPT;
//                    String MODEL;
//                    String NEW_DES;
//                    for(; rs.next(); st1.execute("INSERT INTO TBLNU (ITEM_NO,PART_NO,BRAND,MODEL,CATALOG,DESCRIPT,R_COST,COST,RETAIL,QOH,CONTROL,LI_WARE,position ,part_no ,NEW_DES,NEW_MOD,YR_L,YR_H,REMARK) VALUES('" + rs.getString("ITEM_NO") + "','" + rs.getString("PART_NO") + "','" + rs.getString("BRAND") + "','" + MODEL + "'," + dnk.getCategoryID(rs.getString("CATALOG")) + ",'" + DESCRIPT + "'," + rs.getDouble("R_COST") + "," + rs.getDouble("COST") + "," + rs.getDouble("RETAIL") + "," + rs.getDouble("QOH") + ",'" + rs.getString("CONTROL") + "'," + rs.getDouble("LI_WARE") + ",'" + rs.getString("POSITION") + "','" + NEW_DES + "','" + rs.getString("NEW_MOD") + "'," + rs.getDouble("YR_L") + "," + rs.getDouble("YR_H") + ",'" + rs.getString("REMARK") + "');"))
//                    {
//                        DESCRIPT = rs.getString("DESCRIPT");
//                        DESCRIPT = DESCRIPT.replaceAll("'", " ");
//                        MODEL = rs.getString("MODEL");
//                        MODEL = MODEL.replaceAll("'", " ");
//                        NEW_DES = rs.getString("NEW_DES");
//                        NEW_DES = NEW_DES.replaceAll("'", " ");
//                    }
//
//                }
//            }
//            catch(SQLException er)
//
//            {
//                er.printStackTrace();
//            }
            try  {
                //***Change tblinventory.BeginYr column type from TEXT to NUMBER

                String table = "tblinventory";
                String column = "beginyr";
                String toType = "number";
                AlterColumnType beginyrToNum = new AlterColumnType(table,column,toType);




                //st3.execute("select * from tblnu;");
//                st3.execute("INSERT INTO TBLBCN ( [PART#], SUPPLIER, DESCRIPTION, T24m, T12m, 12MSL, 9msl, 6MSL, 3MSL, INSTOCK, 1mns, 1M, 1_5M, 2M, 3M, 4M, 5M, ONORDER, SHIPPING, TYG_TW, TYG_TX, GD, PROTEC, TYG_TW_P, TYG_TX_P, GD_P, PROTEC_P, TYG_TW_K, TYG_TX_K, GD_K, PROTEC_K, [TYG_TW#], [TYG_TX#], [GD#], [PROTEC#], REMARK, DNK_MEMO, TYG_TW_MEMO, TYG_TX_MEMO, GD_MEMO, PROTEC_MEMO, RATE, TYG_TW_C, TYG_TX_C, GD_C, PROTEC_C, TYG_TW_BO, TYG_TX_BO, GD_BO, PROTEC_BO, OEM_NO, PARTLINK, SUGGEST, TYG_TW_STATUS, TYG_TX_STATUS, GD_STATUS, PROTEC_STATUS, NEW, CAPA, MANUAL ) SELECT ITEM_NO, SUPP, DESCRIPT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IIF(ISNULL(TYG_PRC),0,TYG_PRC), IIF(ISNULL(TX_PRC),0,TX_PRC), IIF(ISNULL(GD_PRC),0,GD_PRC), IIF(ISNULL(PROTEC_PRC),0,PROTEC_PRC), IIF(ISNULL(TYG_PKG),0,TYG_PKG), IIF(ISNULL(TYG_PKG),0,TYG_PKG), IIF(ISNULL(GD_PKG),0,GD_PKG), IIF(ISNULL(PROTEC_PKG),0,PROTEC_PKG), TYG_NO, TX_NO, GD_NO, PROTEC_NO, NULL, DNK_NOTE1, TYG_REMARK, TX_REMARK, GD_REMARK, NULL, 0, IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(GD_CUFT),0,GD_CUFT), IIF(ISNULL(PROT_CUFT),0,PROT_CUFT), 0, 0, 0, 0, PART_NO, PARTLINK, 0, NULL, NULL, NULL, NULL, 0, IIF(CAPA='Y',-1,0), 0 FROM BCMAST WHERE ITEM_NO NOT IN (SELECT [PART#] FROM TBLBCN);");
//                st3.execute("INSERT INTO TBLCLN ( [PART#], SUPPLIER, DESCRIPTION, T24m, T12m, 12MSL, 9msl, 6MSL, 3MSL, INSTOCK, 1mns, 1M, 1_5M, 2M, 3M, 4M, 5M, ONORDER, SHIPPING, TYG_TW, TYG_TX, GD, GN, TYG_TW_P, TYG_TX_P, GD_P, GN_P, TYG_TW_K, TYG_TX_K, GD_K, GN_K, [TYG_TW#], [TYG_TX#], [GD#], [GN#], REMARK, DNK_MEMO, TYG_TW_MEMO, TYG_TX_MEMO, GD_MEMO, GN_MEMO, RATE, TYG_TW_C, TYG_TX_C, GD_C, GN_C, TYG_TW_BO, TYG_TX_BO, GD_BO, GN_BO, OEM_NO, PARTLINK, SUGGEST, TYG_TW_STATUS, TYG_TX_STATUS, GD_STATUS, GN_STATUS, NEW, CAPA, MANUAL ) SELECT ITEM_NO, NULL, DESCRIPT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IIF(ISNULL(TW_TYGPRC),0,TW_TYGPRC), IIF(ISNULL(TX_TYGPRC),0,TX_TYGPRC), IIF(ISNULL(GD_PRC),0,GD_PRC), IIF(ISNULL(GN_PRC),0,GN_PRC), IIF(ISNULL(TW_TYGPKG),0,TW_TYGPKG), IIF(ISNULL(TX_TYGPKG),0,TX_TYGPKG), IIF(ISNULL(GD_PKG),0,GD_PKG), IIF(ISNULL(GN_PKG),0,GN_PKG), TW_TYGNO, TX_TYGNO, GD_NO, GN_NO, NULL, REMARK, TYG_REMARK, NULL, GD_REMARK, NULL, 0, IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(GD_CUFT),0,GD_CUFT), 0, 0, 0, 0, 0, PART_NO, PARTLINK, 0, NULL, NULL, NULL, NULL, 0, 0, 0 FROM COOLNGM WHERE ITEM_NO NOT IN (SELECT [PART#] FROM TBLCLN);");
//                st3.execute("INSERT INTO TBLHFN ( [PART#], SUPPLIER, DESCRIPTION, T24m, T12m, 12MSL, 9msl, 6MSL, 3MSL, INSTOCK, 1mns, 1M, 1_5M, 2M, 3M, 4M, 5M, ONORDER, SHIPPING, TYG_TW, TYG_TX, GD, TYG_TW_P, TYG_TX_P, GD_P, TYG_TW_K, TYG_TX_K, GD_K, [TYG_TW#], [TYG_TX#], [GD#], REMARK, DNK_MEMO, TYG_TW_MEMO, TYG_TX_MEMO, GD_MEMO, RATE, TYG_TW_C, TYG_TX_C, GD_C, TYG_TW_BO, TYG_TX_BO, GD_BO, OEM_NO, PARTLINK, SUGGEST, TYG_TW_STATUS, TYG_TX_STATUS, GD_STATUS, NEW, CAPA, MANUAL ) SELECT ITEM_NO, NULL, DESCRIPT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IIF(ISNULL(TYG_PRC),0,TYG_PRC), IIF(ISNULL(TX_PRC),0,TX_PRC), IIF(ISNULL(GD_PRC),0,GD_PRC), IIF(ISNULL(TYG_PKG),0,TYG_PKG), IIF(ISNULL(TYG_PKG),0,TYG_PKG), IIF(ISNULL(GD_PKG),0,GD_PKG), TYG_NO, TX_NO, GD_NO, NULL, DNK_NOTE1, TYG_REMARK, NULL, GD_REMARK, 0, IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(GD_CUFT),0,GD_CUFT), 0, 0, 0, PART_NO, PARTLINK, 0, NULL, NULL, NULL, 0, IIF(CAPA='Y',-1,0), 0 FROM HFMAST WHERE ITEM_NO NOT IN (SELECT [PART#] FROM TBLHFN);");
//                st3.execute("INSERT INTO TBLLTN ( [PART#], SUPPLIER, DESCRIPTION, t24m, t12m, 12MSL, 9msl, 6MSL, 3MSL, RATE, INSTOCK, 1mns, 1M, 1_5M, 2M, 3M, 4M, 5M, ONORDER, SHIPPING, GD, GENERA, DEPO, ee, REMARK, DNK_MEMO, GD_MEMO, GENERA_MEMO, DEPO_MEMO, EE_MEMO, NEW, GD_P, GENERA_P, DEPO_P, ee_p, GD_K, GENERA_K, DEPO_K, EE_K, [GD#], [GENERA#], [DEPO#], [EE#], GD_C, GENERA_C, DEPO_C, EE_C, GD_BO, GENERA_BO, DEPO_BO, EE_BO, OEM_NO, PARTLINK, SUGGEST, CAPA ) SELECT ITEM_NO, SUPPLIER, DESCRIPT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, REMARK, GD_REMARK, NULL, NULL, NULL, 0, IIF(ISNULL(GD_PRC),0,GD_PRC), IIF(ISNULL(TYC_PRC),0,TYC_PRC), IIF(ISNULL(DEPO_PRC),0,DEPO_PRC), IIF(ISNULL(EAGLEPRC),0,EAGLEPRC), IIF(ISNULL(GD_PKG),0,GD_PKG), IIF(ISNULL(TYC_PKG),0,TYC_PKG), IIF(ISNULL(DEPO_PKG),0,DEPO_PKG), IIF(ISNULL(EAGLEPKG),0,EAGLEPKG), GD_NO, TYC_NO, DEPO_NO, EAGLE_NO, IIF(ISNULL(GD_CUFT),0,GD_CUFT), 0, 0, 0, 0, 0, 0, 0, OEM_NO, PARTLINK, 0, IIF(CAPA = 'Y',-1,0) FROM LT_MAST1 WHERE ITEM_NO NOT IN (SELECT [PART#] FROM TBLLTN);");
//                st3.execute("INSERT INTO TBLMRN ( [PART#], SUPPLIER, DESCRIPTION, T24m, T12m, 12MSL, 9msl, 6MSL, 3MSL, INSTOCK, 1mns, 1M, 1_5M, 2M, 3M, 4M, 5M, ONORDER, SHIPPING, TYG_TW, TYG_TX, GD, GN, KS, TYG_TW_P, TYG_TX_P, GD_P, GN_P, KS_P, KV_P, TYG_TW_K, TYG_TX_K, GD_K, GN_K, KS_K, KV_K, [TYG_TW#], [TYG_TX#], [GD#], [GN#], [KS#], [KV#], REMARK, DNK_MEMO, TYG_TW_MEMO, TYG_TX_MEMO, GD_MEMO, GN_MEMO, KS_MEMO, KV_MEMO, RATE, TYG_TW_C, TYG_TX_C, GD_C, GN_C, KS_C, TYG_TW_BO, TYG_TX_BO, GD_BO, GN_BO, KS_BO, OEM_NO, PARTLINK, SUGGEST, TYG_TW_STATUS, TYG_TX_STATUS, GD_STATUS, GN_STATUS, KS_STATUS, NEW, CAPA, MANUAL ) SELECT ITEM_NO, NULL, DESCRIPT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IIF(ISNULL(TYG_TW_PRC),0,TYG_TW_PRC), IIF(ISNULL(TYG_TX_PRC),0,TYG_TX_PRC), IIF(ISNULL(GD_PRC),0,GD_PRC), IIF(ISNULL(GN_PRC),0,GN_PRC), IIF(ISNULL(AM_PRC),0,AM_PRC), IIF(ISNULL(KV_PRC),0,KV_PRC), IIF(ISNULL(TYG_TW_PKG),0,TYG_TW_PKG), IIF(ISNULL(TYG_TX_PKG),0,TYG_TX_PKG), IIF(ISNULL(GD_PKG),0,GD_PKG), IIF(ISNULL(GN_PKG),0,GN_PKG), IIF(ISNULL(AM_PKG),0,AM_PKG), IIF(ISNULL(KV_PKG),0,KV_PKG), TYG_TW_NO, TYG_TX_NO, GD_NO, GN_NO, AM_NO, KV_NO, NULL, REMARK, TYG_REMARK, TX_REMARK, GD_REMARK, GN_REMARK, NULL, KV_REMARK, 0, IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(GD_CUFT),0,GD_CUFT), 0, 0, 0, 0, 0, 0, 0, PART_NO, PARTLINK, 0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 FROM MIRRORM1 WHERE ITEM_NO NOT IN (SELECT [PART#] FROM TBLMRN);");
//                st3.execute("INSERT INTO TBLOTN ( [PART#], SUPPLIER, DESCRIPTION, T24m, T12m, 12MSL, 9msl, 6MSL, 3MSL, INSTOCK, 1mns, 1M, 1_5M, 2M, 3M, 4M, 5M, ONORDER, SHIPPING, TYG_TW, TYG_TX, GD, PROTEC, FEY, TYG_TW_P, TYG_TX_P, GD_P, PROTEC_P, FEY_P, TYG_TW_K, TYG_TX_K, GD_K, PROTEC_K, FEY_K, [TYG_TW#], [TYG_TX#], [GD#], [PROTEC#], [FEY#], REMARK, DNK_MEMO, TYG_TW_MEMO, TYG_TX_MEMO, GD_MEMO, PROTEC_MEMO, FEY_MEMO, RATE, TYG_TW_C, TYG_TX_C, GD_C, PROTEC_C, FEY_C, TYG_TW_BO, TYG_TX_BO, GD_BO, PROTEC_BO, FEY_BO, OEM_NO, PARTLINK, SUGGEST, TYG_TW_STATUS, TYG_TX_STATUS, GD_STATUS, PROTEC_STATUS, FEY_STATUS, NEW, CAPA, MANUAL ) SELECT ITEM_NO, SUPP, DESCRIPT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IIF(ISNULL(TYG_PRC),0,TYG_PRC), IIF(ISNULL(TX_PRC),0,TX_PRC), IIF(ISNULL(GD_PRC),0,GD_PRC), IIF(ISNULL(PROTEC_PRC),0,PROTEC_PRC), 0, IIF(ISNULL(TYG_PKG),0,TYG_PKG), IIF(ISNULL(TYG_PKG),0,TYG_PKG), IIF(ISNULL(GD_PKG),0,GD_PKG), IIF(ISNULL(PROTEC_PKG),0,PROTEC_PKG), 0, TYG_NO, TX_NO, GD_NO, PROTEC_NO, NULL, NULL, DNK_NOTE1, TYG_REMARK, TX_REMARK, GD_REMARK, NULL, NULL, 0, IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(GD_CUFT),0,GD_CUFT), IIF(ISNULL(PROT_CUFT),0,PROT_CUFT), 0, 0, 0, 0, 0, 0, PART_NO, PARTLINK, 0, NULL, NULL, NULL, NULL, NULL, 0, IIF(CAPA='Y',-1,0), 0 FROM OTMAST WHERE ITEM_NO NOT IN (SELECT [PART#] FROM TBLOTN);");

                //int rowsupdated = stli.executeUpdate(st[x]);
//                System.out.println("Total record Updated : "+rowsupdated);

                //CL and MR no CAPA field
                int rowsupdated=0;

                rowsupdated =st.executeUpdate("INSERT INTO bcmast   ( [Item_no], DESCRIPT    ,capa   ,partlink   ,position ,part_no  ) \n" +
                        "SELECT                     [Part#],  Description   ,capa   ,partslink  ,position , [product#]  \n" +
                        "FROM tblinventory WHERE [Part#] NOT IN (SELECT [Item_no] FROM bcmast) AND CategoryID=1 AND beginyr>1990;");
//                System.out.print("Total record Updated : "+rowsupdated);
//                System.out.println("  BC Complete, HF begin...");

                rowsupdated =st1.executeUpdate("INSERT INTO hfmast   ( [Item_no], DESCRIPT    ,capa   ,partlink   ,position ,part_no  ) \n" +
                        "SELECT                     [Part#],  Description   ,capa   ,partslink  ,position ,[product#]  \n" +
                        "FROM tblinventory WHERE [Part#] NOT IN (SELECT [Item_no] FROM hfmast) AND CategoryID=2 AND beginyr>1990;");
//                System.out.print("Total record Updated : "+rowsupdated);
//                System.out.println("  HF Complete, LT begin...");

                rowsupdated =st2.executeUpdate("INSERT INTO lt_mast1   ( [Item_no], DESCRIPT    ,capa   ,partlink   ,position ,oem_no  ) \n" +
                        "SELECT                     [Part#],  Description   ,capa   ,partslink  ,position ,[product#]  \n" +
                        "FROM tblinventory WHERE [Part#] NOT IN (SELECT [Item_no] FROM lt_mast1) AND CategoryID=3 AND beginyr>1990;");
//                System.out.print("Total record Updated : "+rowsupdated);
//                System.out.println("  LT Complete, CL begin...");

                rowsupdated =st3.executeUpdate("INSERT INTO coolngm   ( [Item_no], DESCRIPT       ,partlink   ,position ,part_no  ) \n" +
                        "SELECT                     [Part#],  Description       ,partslink  ,position ,[product#]  \n" +
                        "FROM tblinventory WHERE [Part#] NOT IN (SELECT [Item_no] FROM coolngm) AND CategoryID=4 AND beginyr>1990;");
//                System.out.print("Total record Updated : "+rowsupdated);
//                System.out.println("  CL Complete, MR begin...");

                rowsupdated =st4.executeUpdate("INSERT INTO mirrorm1   ( [Item_no], DESCRIPT     ,partlink   ,position ,part_no  ) \n" +
                        "SELECT                     [Part#],  Description      ,partslink  ,position ,[product#]  \n" +
                        "FROM tblinventory WHERE [Part#] NOT IN (SELECT [Item_no] FROM mirrorm1) AND CategoryID=5 AND beginyr>1990;");
//                System.out.print("Total record Updated : "+rowsupdated);
//                System.out.println("  MR Complete, OT begin...");

                rowsupdated =st5.executeUpdate("INSERT INTO otmast   ( [Item_no], DESCRIPT    ,capa   ,partlink   ,position ,part_no  ) \n" +
                        "SELECT                     [Part#],  Description   ,capa   ,partslink  ,position ,[product#]  \n" +
                        "FROM tblinventory WHERE [Part#] NOT IN (SELECT [Item_no] FROM otmast) AND CategoryID=6 AND beginyr>1990;");
//                System.out.print("Total record Updated : "+rowsupdated);
//                System.out.println("  OT Complete, All done! (yr.1990+)\n");



                //***Change tblinventory.BeginYr column type from NUMBER to TEXT
                 table = "tblinventory";
                 column = "beginyr";
                 toType = "text";
                AlterColumnType beginyrToText = new AlterColumnType(table,column,toType);


//                st3.execute("INSERT INTO coolngm1  ( [PART#], SUPPLIER, DESCRIPTION, T24m, T12m, 12MSL, 9msl, 6MSL, 3MSL,           INSTOCK, 1mns, 1M, 1_5M, 2M, 3M, 4M, 5M, ONORDER, SHIPPING, TYG_TW, TYG_TX, GD, GN, TYG_TW_P, TYG_TX_P, GD_P, GN_P, TYG_TW_K, TYG_TX_K, GD_K, GN_K, [TYG_TW#], [TYG_TX#], [GD#], [GN#], REMARK, DNK_MEMO, TYG_TW_MEMO, TYG_TX_MEMO, GD_MEMO, GN_MEMO, RATE, TYG_TW_C, TYG_TX_C, GD_C, GN_C, TYG_TW_BO, TYG_TX_BO, GD_BO, GN_BO, OEM_NO, PARTLINK, SUGGEST, TYG_TW_STATUS, TYG_TX_STATUS, GD_STATUS, GN_STATUS, NEW, CAPA, MANUAL ) " +
//                        "SELECT ITEM_NO, NULL, DESCRIPT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IIF(ISNULL(TW_TYGPRC),0,TW_TYGPRC), IIF(ISNULL(TX_TYGPRC),0,TX_TYGPRC), IIF(ISNULL(GD_PRC),0,GD_PRC), IIF(ISNULL(GN_PRC),0,GN_PRC), IIF(ISNULL(TW_TYGPKG),0,TW_TYGPKG), IIF(ISNULL(TX_TYGPKG),0,TX_TYGPKG), IIF(ISNULL(GD_PKG),0,GD_PKG), IIF(ISNULL(GN_PKG),0,GN_PKG), TW_TYGNO, TX_TYGNO, GD_NO, GN_NO, NULL, REMARK, TYG_REMARK, NULL, GD_REMARK, NULL, 0, IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(GD_CUFT),0,GD_CUFT), 0, 0, 0, 0, 0, PART_NO, PARTLINK, 0, NULL, NULL, NULL, NULL, 0, 0, 0 " +
//                        "FROM tblinventory WHERE ITEM_NO NOT IN (SELECT [PART#] FROM coolngm1) AND CategoryID=4;");
//                st3.execute("INSERT INTO hfmast1   ( [PART#], SUPPLIER, DESCRIPTION, T24m, T12m, 12MSL, 9msl, 6MSL, 3MSL,           INSTOCK, 1mns, 1M, 1_5M, 2M, 3M, 4M, 5M, ONORDER, SHIPPING, TYG_TW, TYG_TX, GD, TYG_TW_P, TYG_TX_P, GD_P, TYG_TW_K, TYG_TX_K, GD_K, [TYG_TW#], [TYG_TX#], [GD#], REMARK, DNK_MEMO, TYG_TW_MEMO, TYG_TX_MEMO, GD_MEMO, RATE, TYG_TW_C, TYG_TX_C, GD_C, TYG_TW_BO, TYG_TX_BO, GD_BO, OEM_NO, PARTLINK, SUGGEST, TYG_TW_STATUS, TYG_TX_STATUS, GD_STATUS, NEW, CAPA, MANUAL ) " +
//                        "SELECT ITEM_NO, NULL, DESCRIPT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IIF(ISNULL(TYG_PRC),0,TYG_PRC), IIF(ISNULL(TX_PRC),0,TX_PRC), IIF(ISNULL(GD_PRC),0,GD_PRC), IIF(ISNULL(TYG_PKG),0,TYG_PKG), IIF(ISNULL(TYG_PKG),0,TYG_PKG), IIF(ISNULL(GD_PKG),0,GD_PKG), TYG_NO, TX_NO, GD_NO, NULL, DNK_NOTE1, TYG_REMARK, NULL, GD_REMARK, 0, IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(GD_CUFT),0,GD_CUFT), 0, 0, 0, PART_NO, PARTLINK, 0, NULL, NULL, NULL, 0, IIF(CAPA='Y',-1,0), 0 " +
//                        "FROM tblinventory WHERE ITEM_NO NOT IN (SELECT [PART#] FROM hfmast1) AND CategoryID=2;");
//                st3.execute("INSERT INTO lt_mast11 ( [PART#], SUPPLIER, DESCRIPTION, t24m, t12m, 12MSL, 9msl, 6MSL, 3MSL, RATE,     INSTOCK, 1mns, 1M, 1_5M, 2M, 3M, 4M, 5M, ONORDER, SHIPPING, GD, GENERA, DEPO, ee, REMARK, DNK_MEMO, GD_MEMO, GENERA_MEMO, DEPO_MEMO, EE_MEMO, NEW, GD_P, GENERA_P, DEPO_P, ee_p, GD_K, GENERA_K, DEPO_K, EE_K, [GD#], [GENERA#], [DEPO#], [EE#], GD_C, GENERA_C, DEPO_C, EE_C, GD_BO, GENERA_BO, DEPO_BO, EE_BO, OEM_NO, PARTLINK, SUGGEST, CAPA ) " +
//                        "SELECT ITEM_NO, SUPPLIER, DESCRIPT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, REMARK, GD_REMARK, NULL, NULL, NULL, 0, IIF(ISNULL(GD_PRC),0,GD_PRC), IIF(ISNULL(TYC_PRC),0,TYC_PRC), IIF(ISNULL(DEPO_PRC),0,DEPO_PRC), IIF(ISNULL(EAGLEPRC),0,EAGLEPRC), IIF(ISNULL(GD_PKG),0,GD_PKG), IIF(ISNULL(TYC_PKG),0,TYC_PKG), IIF(ISNULL(DEPO_PKG),0,DEPO_PKG), IIF(ISNULL(EAGLEPKG),0,EAGLEPKG), GD_NO, TYC_NO, DEPO_NO, EAGLE_NO, IIF(ISNULL(GD_CUFT),0,GD_CUFT), 0, 0, 0, 0, 0, 0, 0, OEM_NO, PARTLINK, 0, IIF(CAPA = 'Y',-1,0) " +
//                        "FROM tblinventory WHERE ITEM_NO NOT IN (SELECT [PART#] FROM lt_mast11) AND CategoryID=3;");
//                st3.execute("INSERT INTO mirrorm11 ( [PART#], SUPPLIER, DESCRIPTION, T24m, T12m, 12MSL, 9msl, 6MSL, 3MSL,           INSTOCK, 1mns, 1M, 1_5M, 2M, 3M, 4M, 5M, ONORDER, SHIPPING, TYG_TW, TYG_TX, GD, GN, KS, TYG_TW_P, TYG_TX_P, GD_P, GN_P, KS_P, KV_P, TYG_TW_K, TYG_TX_K, GD_K, GN_K, KS_K, KV_K, [TYG_TW#], [TYG_TX#], [GD#], [GN#], [KS#], [KV#], REMARK, DNK_MEMO, TYG_TW_MEMO, TYG_TX_MEMO, GD_MEMO, GN_MEMO, KS_MEMO, KV_MEMO, RATE, TYG_TW_C, TYG_TX_C, GD_C, GN_C, KS_C, TYG_TW_BO, TYG_TX_BO, GD_BO, GN_BO, KS_BO, OEM_NO, PARTLINK, SUGGEST, TYG_TW_STATUS, TYG_TX_STATUS, GD_STATUS, GN_STATUS, KS_STATUS, NEW, CAPA, MANUAL ) " +
//                        "SELECT ITEM_NO, NULL, DESCRIPT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IIF(ISNULL(TYG_TW_PRC),0,TYG_TW_PRC), IIF(ISNULL(TYG_TX_PRC),0,TYG_TX_PRC), IIF(ISNULL(GD_PRC),0,GD_PRC), IIF(ISNULL(GN_PRC),0,GN_PRC), IIF(ISNULL(AM_PRC),0,AM_PRC), IIF(ISNULL(KV_PRC),0,KV_PRC), IIF(ISNULL(TYG_TW_PKG),0,TYG_TW_PKG), IIF(ISNULL(TYG_TX_PKG),0,TYG_TX_PKG), IIF(ISNULL(GD_PKG),0,GD_PKG), IIF(ISNULL(GN_PKG),0,GN_PKG), IIF(ISNULL(AM_PKG),0,AM_PKG), IIF(ISNULL(KV_PKG),0,KV_PKG), TYG_TW_NO, TYG_TX_NO, GD_NO, GN_NO, AM_NO, KV_NO, NULL, REMARK, TYG_REMARK, TX_REMARK, GD_REMARK, GN_REMARK, NULL, KV_REMARK, 0, IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(GD_CUFT),0,GD_CUFT), 0, 0, 0, 0, 0, 0, 0, PART_NO, PARTLINK, 0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 " +
//                        "FROM tblinventory WHERE ITEM_NO NOT IN (SELECT [PART#] FROM mirrorm11) AND CategoryID=5;");
//                st3.execute("INSERT INTO otmast1   ( [PART#], SUPPLIER, DESCRIPTION, T24m, T12m, 12MSL, 9msl, 6MSL, 3MSL,           INSTOCK, 1mns, 1M, 1_5M, 2M, 3M, 4M, 5M, ONORDER, SHIPPING, TYG_TW, TYG_TX, GD, PROTEC, FEY, TYG_TW_P, TYG_TX_P, GD_P, PROTEC_P, FEY_P, TYG_TW_K, TYG_TX_K, GD_K, PROTEC_K, FEY_K, [TYG_TW#], [TYG_TX#], [GD#], [PROTEC#], [FEY#], REMARK, DNK_MEMO, TYG_TW_MEMO, TYG_TX_MEMO, GD_MEMO, PROTEC_MEMO, FEY_MEMO, RATE, TYG_TW_C, TYG_TX_C, GD_C, PROTEC_C, FEY_C, TYG_TW_BO, TYG_TX_BO, GD_BO, PROTEC_BO, FEY_BO, OEM_NO, PARTLINK, SUGGEST, TYG_TW_STATUS, TYG_TX_STATUS, GD_STATUS, PROTEC_STATUS, FEY_STATUS, NEW, CAPA, MANUAL ) " +
//                        "SELECT ITEM_NO, SUPP, DESCRIPT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IIF(ISNULL(TYG_PRC),0,TYG_PRC), IIF(ISNULL(TX_PRC),0,TX_PRC), IIF(ISNULL(GD_PRC),0,GD_PRC), IIF(ISNULL(PROTEC_PRC),0,PROTEC_PRC), 0, IIF(ISNULL(TYG_PKG),0,TYG_PKG), IIF(ISNULL(TYG_PKG),0,TYG_PKG), IIF(ISNULL(GD_PKG),0,GD_PKG), IIF(ISNULL(PROTEC_PKG),0,PROTEC_PKG), 0, TYG_NO, TX_NO, GD_NO, PROTEC_NO, NULL, NULL, DNK_NOTE1, TYG_REMARK, TX_REMARK, GD_REMARK, NULL, NULL, 0, IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(TYG_CUFT),0,TYG_CUFT), IIF(ISNULL(GD_CUFT),0,GD_CUFT), IIF(ISNULL(PROT_CUFT),0,PROT_CUFT), 0, 0, 0, 0, 0, 0, PART_NO, PARTLINK, 0, NULL, NULL, NULL, NULL, NULL, 0, IIF(CAPA='Y',-1,0), 0 " +
//                        "FROM tblinventory WHERE ITEM_NO NOT IN (SELECT [PART#] FROM otmast1) AND CategoryID=6 ;");

//                ResultSet rs1 = st3.getResultSet();
//                if(rs1 != null)
//                    while(rs1.next())
//                    {
//                        String CONTROL = rs1.getString("CONTROL").replaceAll("null", " ");
//                        String mmo = (new StringBuilder()).append(CONTROL).append(rs1.getString("REMARK")).toString();
//                        String mmo1 = mmo.trim();
//                        try
//                        {
//                            st2.execute((new StringBuilder()).append("INSERT INTO tblinventory ( categoryid, [part#], description, unittype, unit, unitcost, sellingprice, instock, onorder, onhold, onrma, parvalue, location, serialized, [vendor#], discontinued, weight, taxable, vendor1id, vendor2id, vendor3id, lpp, lpf, ldp, lqp, [upc#], revenueglid, inventoryglid, currentcost, warehouseid, [product#], internet, internetprice, cogid, addinfulfillmentallowed, make, mdl, modeltype, beginyr, endyr, prefix, nagscode, dnkcode, cif, retailprice, sellingprice2, [memo], westwp, fob_t, ecp, ppgprice, slprice, mprice, shapeid, country, [bin#], prpkey, ppgloc, instock1, POSITION, NEW_DES ) SELECT top 1 b.CATALOG, b.item_no, b.descript, NULL, NULL, b.r_cost, b.retail, b.qoh, 0, 0, 0, 0, b.location, no, NULL, no, 0, yes, 0, 0, 0, 0, 0, 0, 0, NULL, 1, 1, 0, 2, b.part_no, yes, b.retail, 1, yes, b.brand, B.MODEL, B.NEW_MOD, b.yr_l, b.yr_h, NULL, NULL, b.item_no, b.cost, b.retail, b.retail, '").append(mmo1).append("', 0, 0, ").append("0, 0, 0, 0, 18, NULL, NULL, 0, NULL, ").append("B.LI_WARE, POSITION, NEW_DES ").append("FROM TBLNU AS b where b.item_no ='").append(rs1.getString("ITEM_NO")).append("';").toString());
//                        }
//                        catch(SQLException er) { }
//                    }
            }
            catch(SQLException er)
            {
                //***Change tblinventory.BeginYr column type from TEXT to NUMBER when script fails

                String table = "tblinventory";
                String column = "beginyr";
                String toType = "number";
                AlterColumnType beginyrToNum = new AlterColumnType(table,column,toType);

                er.printStackTrace();

            }
//            try
//            {
//                st5.execute("INSERT INTO tblmodel ( [part#], make, mdl, modeltype, Description, Beginyr, Endyr, WarehouseID, position, new_des ) SELECT item_no, brand, model, new_mod, descript, yr_l, yr_h, 2, position, new_des FROM tblnu;");
//            }
//            catch(SQLException er) { }
//            try
//            {
//                st6.execute("INSERT INTO TBLINVENTORYCOSTING ( INVID, QTY, DATERECEIVED, USED, COST, VENDORID ) SELECT DISTINCT A.INVID, A.INSTOCK, NOW(), 0, 0, NULL FROM TBLINVENTORY AS A INNER JOIN tblnu AS B ON A.[PART#]=B.[ITEM_NO];");
//            }
//            catch(SQLException er) { }
            st.close();
            st1.close();
            st2.close();
            st3.close();
            st4.close();
            st5.close();
            st6.close();
            con.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}
